/*
 * DebugConsole.cpp
 *
 *  Created on: 2011. 3. 15.
 *      Author: JeeHoon
 */
#include "plugin/DebugConsole.h"
#include "api/PluginManager.h"
#include "api/PluginResult.h"

using namespace Osp::Base;

DebugConsole::DebugConsole()
{
}

DebugConsole::~DebugConsole()
{
}

result
DebugConsole::OnConstruct(PluginManager * pPluginManager, Osp::Base::String pluginName)
{
	result r = E_SUCCESS;

	return r;
}

result
DebugConsole::execute(Osp::Base::String action, Osp::Base::String args, Osp::Base::String callbackId)
{
	result r = E_SUCCESS;

	if(action == L"log")
	{
		if(getJSONObjectItem(args,L"logLevel") == L"\"INFO\"")
		{
			printLog(L"Phone Gap INFO: "+URLDecode(callbackId));
		}
		else if(getJSONObjectItem(args,L"logLevel") == L"\"WARN\"")
		{
			printLog(L"Phone Gap WARN: "+URLDecode(callbackId));
		}
		else if(getJSONObjectItem(args,L"logLevel") == L"\"ERROR\"")
		{
			printLog(L"Phone Gap ERROR: "+URLDecode(callbackId));
		}
		else
		{
			printLog(L"Unknown logLevel: "+getJSONObjectItem(args,L"logLevel"));
		}
	}
	else
	{
		printLog(L"Unknown action: " + action);
	}

	return r;
}
